#登录页面
from selenium.webdriver.common.by import By
from utils.page_base import PageBase #导入页面基类

class PageLogin(PageBase):
    pathUrl="/simple/login"
    loc_zanhao=By.NAME,"login_info"
    loc_pwd=By.NAME,"password"
    loc_login=By.CSS_SELECTOR,"input[type='submit'][value='登录']"
    loc_errorTipDiv=By.CSS_SELECTOR,"div.prompt"

    def __init__(self,driver,base_url):
        PageBase.__init__(self,driver,base_url)

    def openUrl(self):
        self.open(PageLogin.pathUrl)


    #输入账户
    def input_zanhao(self,zanhao):
        self.input(PageLogin.loc_zanhao,zanhao)

    #输入密码
    def input_pwd(self,pwd):
        self.input(PageLogin.loc_pwd,pwd)

    #点击“登录按钮”
    def click_login(self):
        self.click(PageLogin.loc_login)

    #获取错误提示div标签的文本内容：去掉空格
    def getErrorTipDivText(self):
        return self.getEleText(PageLogin.loc_errorTipDiv)

    #获取账户元素的class属性的值
    def getZanhaoEleAttrClass(self):#"xxx invalie-text"
        return self.getEleAttr(PageLogin.loc_zanhao,"class")

    #获取密码元素的class属性的值
    def getPwdEleAttrClass(self):
        return self.getEleAttr(PageLogin.loc_pwd,"class")

